package com.woniu.service.impl;

import com.woniu.mapper.DashboardMapper;
import com.woniu.service.DashboardService;
import com.woniu.utils.ResponseEnum;
import com.woniu.utils.ResponseUtil;
import com.woniu.vo.MedicalRoomVO;
import com.woniu.vo.WardBedVO;
import com.woniu.vo.WardPatientBedVO;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class DashboardServiceImpl implements DashboardService {
    @Resource
    private DashboardMapper dashboardMapper;
    @Override
    public ResponseUtil listMedicalRooms() {
        List<MedicalRoomVO> medicalRooms
                = dashboardMapper.findAllMedicalRooms();
        return medicalRooms.size() > 0 ?
                ResponseUtil.get(ResponseEnum.OK,medicalRooms)
                : ResponseUtil.get(ResponseEnum.FAIL);
    }

    @Override
    public ResponseUtil getWardAndBedStatus(Integer departmentId) {
        List<WardBedVO> wardAndBedStatus
                = dashboardMapper
                .findWardsAndBedsByDepartment(departmentId);
        return wardAndBedStatus.size() > 0 ?
                ResponseUtil.get(ResponseEnum.OK,wardAndBedStatus)
                : ResponseUtil.get(ResponseEnum.FAIL);
    }

    @Override
    public ResponseUtil getWardAndPatientBedStatus(Integer departmentId) {
        List<WardPatientBedVO> list
                = dashboardMapper
                .findWardsAndPatientBedsByDepartment(departmentId);
        return list.size() > 0 ?
                ResponseUtil.get(ResponseEnum.OK,list)
                : ResponseUtil.get(ResponseEnum.FAIL);
    }
}
